home *** CD-ROM | disk | FTP | other *** search
- ;
- ; play raw sound files through the pc's internal speaker
- ; code by Semih Hazar
- ;
- ; wait for the background music playing routines !
- ; have ideas about that ^ put an e-mail to hazarse@doruk.com.tr
- ;
-
- BitsPerSample Equ 64 ; # of bits per samle (1sample = 1byte)
-
- .model tiny
- .code
- org 100h
-
-
- main : mov ax,3d00h ; open data file and read the sound
- lea dx,file
- int 21h
- mov bx,ax
- mov ah,3fh
- mov cx,20000
- lea dx,buf
- int 21h
- mov boy,ax
- mov ah,3eh
- int 21h
-
- call set_hi_an_lo
- call MakePCStable
-
- mov cx,boy
- lea si,buf
- ploop : lodsb
- push si
- push cx
- mov si,offset pcstable
- xor ah,ah
- mov cl,bitspersample
- mul cl
- add si,ax
- mov cx,bitspersample
- bitlp : lodsb
- out 61h,al
- loop bitlp
- pop cx
- pop si
- loop ploop
- mov ah,4ch
- int 21h
-
- set_hi_an_lo proc near
- ; consider the hi and lo value depending on the port61's current status
- in al,61h
- mov cl,3
- not cl
- and al,cl
- mov _cl,al ; this one's low
- or al,2
- mov _ch,al ; and this is hi
- ret
- set_hi_an_lo endp
-
- MakePCStable proc near
- ; make a table for the 256 samples (0-255).
- ; this atble is bitspersample**256 bytes long
- ; each (bitspersample) byte is the bit patterns (hi or low)
- ; these patterns are send out to 61h ,then the sound forms...
- mov di,offset PCStable
- mov cx,256
- mov mainval,0
- mainloop : push cx
- mov sum,0
- mov cx,BitsPerSample
- bits_loop : mov bl,mainval
- xor bh,bh
- add sum,bx
- cmp sum,255
- jae bigger
- mov al,_cl
- stosb
- eobl : loop bits_loop
- pop cx
- inc mainval
- loop mainloop
- ret
-
- bigger : mov ax,255
- sub sum,ax
- mov al,_ch
- stosb
- jmp short eobl
-
- MakePCStable endp
-
-
- file db 'ses',0
- sum dw 0
- mainval db 0
- _ch db 0
- _cl db 0
- boy dw 0
- PCStable db (BitsPerSample*256) dup(?)
- buf db 20000 dup(?)
-
- end main
-